/**********************************************************************************
// Missile
// 
// Creation:	14 Set 2008
// Updated:		27 Set 2008
// Compiler:	Visual Studio 2008
//
// Notes:		Defines a missile for asteroids game
//
**********************************************************************************/

#include "Missile.h"

/**********************************************************************************/

Missile::Missile(SpaceShip &s)
{
	// set direction and speed of missile
	speed.SetVector(s.Direction().Ang(), 15.0f);
	
	// get the position for the top of the ship
	// distance from center to top of the ship is 10 pixels
	float x = 10 * cos(s.Direction().Rad());
	float y = -10 * sin(s.Direction().Rad());

	// make the top of the ship the starting position for the missile
	MoveTo(s.x + x, s.y + y);
	color = Color(255,255,0);

	customType = objMissile;  // missile type object
}

/**********************************************************************************/

Missile::Missile(float posX, float posY, Vector2 dir)
{
	// set direction and speed of missile
	speed.SetVector(dir.Ang(), dir.Mag());
	
	// set missile initial position
	MoveTo(posX, posY);

	// missile type object
	customType = objMissile; 
}

/**********************************************************************************/

void Missile::Move()
{
	// Translate missile by its speed 
	Translate(speed.GetX(), -1.0f * speed.GetY());
}

/**********************************************************************************/
